package com.addzero.web.ui.hooks.tree

import androidx.compose.material3.OutlinedButton
import androidx.compose.material3.Text
import androidx.compose.runtime.Composable
import androidx.compose.runtime.getValue
import androidx.compose.runtime.mutableStateOf
import androidx.compose.runtime.setValue
import com.addzero.web.ui.hooks.UseHook

/**
 * 编辑模式组件
 * 允许用户切换树结构的编辑模式
 */
class UseEditMode(private val initialEditFlag: Boolean = false) : UseHook<UseEditMode> {
    // 是否处于编辑模式
    var editFlag by mutableStateOf(false)

    override val render: @Composable () -> Unit
        get() = {
            if (initialEditFlag) {
                OutlinedButton(
                    onClick = {
                        editFlag = !editFlag
                    },
                    content = { Text("编辑模式") }
                )

            }

        }
}
